﻿package com.pool.data
{
	import SpLib.Net.RPC;
	
	public class Common
	{
		public static const cltVer:String = "Debug_Ver";
		public static const gameSite:String = "测试";
		public static const gameType:String = "台球16球";
		public static const serverIP:Array = ["60.190.81.229", 20000];
		
		public static const DEF_RPC_OUTTIME:int	= 30*1000;
		
		public static const USERNOMAL:int=0;
		public static const USERINROOM:int=1;
		public static const USERINDESK:int=2;
		public static const USERREADY:int=3;
		public static const USERINGAME:int=4;
		
		//public static var serverIP:Array = ["60.190.81.229", 20000];
		//public static var serverIP:Array = ["192.168.1.124", 20000];
		
		public function Common()
		{
		}
		
		//public static function connected(onConnetOk:Function):void 
		//{
			//if(!SpLib.Net.NetMsgMgr.IsConnected())
			//{
				//var socket:SpLib.Net.Socket = SpLib.Net.NetMsgMgr.Connect(Common.serverIP[0],Common.serverIP[1]).addEventListener;
				//SpLib.Net.NetMsgMgr.Connect(Common.serverIP[0],Common.serverIP[1]).addEventListener(SpLibEvent.NET_CONNECTED,OnConnectOk);
			//}
			//else
			//{
				//OnConnectOk(new SpLibEvent(SpLibEvent.NET_CONNECTED));
			//}
		//}
		
		private static function FillSName(sname:String):String
		{
			var idx:int = sname.search("人员");
			if(idx<0) return "Qin::"+sname;
			return "Qin::User/" + gameType + "/" + sname;
		}
		
		public static function Call(sname:String,eve:String,agv:Array,okfunc:Function,errfunc:Function,outtime:int=DEF_RPC_OUTTIME,extagv:Array=null):void
		{
			sname = FillSName(sname);
			SpLib.Net.RPC.Call(sname,eve,agv,okfunc,errfunc,outtime,extagv);
		}

		public static function Send(sname:String,eve:String,agv:Array):void
		{
			sname = FillSName(sname);
			SpLib.Net.RPC.Send(sname,eve,agv);
		}
		
		public static function RegCallBack(sname:String,eve:String,agv:Array,func:Function,loop:Boolean = false,loopdelay:int=0):void
		{
			sname = FillSName(sname);
			SpLib.Net.RPC.RegCallBack(sname,eve,agv,func,loop,loopdelay);
		}
	}
}